package com.yuye.utils;

import java.io.InputStream;
import java.util.Properties;

/**
 * Created by yuye on 2017/4/25.
 */
public class Global {
    static private String adminPath = null;
    static private String frontPath = null;
    static{
        loads();
    }
    synchronized static public void loads(){
        if(adminPath == null || frontPath == null)
        {
            InputStream is = Global.class.getResourceAsStream("/config.properties");
            Properties configProps = new Properties();
            try {
                configProps.load(is);
                adminPath = configProps.getProperty("adminPath");
                frontPath = configProps.getProperty("frontPath");
            }
            catch (Exception e) {
                System.err.println("不能读取属性文件. " +
                        "请确保config.properties在CLASSPATH指定的路径中");
            }
        }
    }
    public static String getAdminPath(){
        if(adminPath!=null){
            loads();
        }
        return adminPath;
    }
    public static String getFrontPath(){
        if(frontPath!=null){
            loads();
        }
        return frontPath;
    }
}
